home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1999 #1 / Amiga Plus 1999 #1.iso / System-Boost / Workbench / BackClock / sources / partial.c < prev    next >
C/C++ Source or Header  |  1998-08-10  |  4KB  |  138 lines

  1. /*****************************************************************************
  2.  * 
  3.  * name                    : partial.c
  4.  * description            : close & reopen window on workbench close
  5.  * version                : 2.1ß2
  6.  *
  7.  * created                : ?
  8.  * last change            : 14-07-98
  9.  *
  10.  * version 2.1: bugfixed (sizing and dragging gadget)
  11.  * version 2.1ß2 : now open the window as backdrop
  12.  *****************************************************************************
  13.  */
  14. #include "utils.h"
  15. #include "partial.h"
  16. #include "obp.h"
  17. #include <proto/intuition.h>
  18. #include <proto/exec.h>
  19.  
  20.  
  21. BOOL partialClose(idWin * prj) {
  22.   /* 
  23.    * handle notify_intuition msg
  24.    * close the window 
  25.    * 
  26.    */
  27.   BOOL ret = FALSE ;
  28.   struct Message * msg ;
  29.   struct IntNotifyMessage * imsg ;
  30.   
  31.   msg = GetMsg(prj->notifyPort) ;
  32.   imsg = (struct IntNotifyMessage*)msg ;
  33.  
  34.   if (imsg->inm_Code == 0x200) {
  35.     /* close the window
  36.      */
  37.     if (prj->win) {  
  38.       CloseWindow(prj->win) ;
  39.       prj->win = NULL ;      // in case of error
  40.       ret = TRUE ;
  41.     }
  42.   }
  43.   if (msg) ReplyMsg(msg) ;
  44.   
  45.   return(ret) ;
  46. }
  47.  
  48.  
  49. void partialOpen(idWin * prj) {
  50.   /* reopen the window
  51.    */
  52.   struct Screen * WBScreen = NULL ;
  53.   struct Message * msg ;
  54.   struct IntNotifyMessage * imsg ;
  55.   UWORD code ;
  56.   ULONG mask ;
  57.   
  58.   do{
  59.     /* get msg from notifyintuition
  60.      */
  61.     mask = Wait(1<<(prj->notifyPort->mp_SigBit)) ;
  62.     if ((msg = GetMsg(prj->notifyPort)) != NULL) {
  63.       /* received a msg
  64.        */
  65.       imsg = (struct IntNotifyMessage *)msg ;
  66.       code = imsg->inm_Code ;
  67.       ReplyMsg(msg) ;
  68.     }
  69.   }while(code != 0x100) ;
  70.    
  71.   WBScreen = LockPubScreen("Workbench") ;
  72.   prj->wb = WBScreen ;
  73.   free_bitmap(prj) ;
  74.   init_bitmap(prj) ;
  75.   prj->win = OpenWindowTags(NULL, WA_Left,    prj->backWin.posX,
  76.                                              WA_Top,        prj->backWin.posY,
  77.                                              WA_Width,    prj->backWin.width,
  78.                                              WA_Height,    prj->backWin.height,
  79.                                              WA_IDCMP,    IDCMP,
  80.                                  WA_MinWidth,     50,
  81.                                  WA_MinHeight,   50,
  82.                                  WA_MaxHeight,   200,
  83.                                  WA_MaxWidth,    200, 
  84.                                              WA_Flags,    WFLG,
  85.                                              WA_ScreenTitle, TXT_SCRTITLE, 
  86.                                              WA_NewLookMenus, TRUE,
  87.                                              WA_PubScreenName, "Workbench", TAG_DONE) ;
  88.   RemoveGList(prj->win, &szgdg, 2) ;
  89.                                              
  90.   szgdg.Width  = prj->win->Width ;
  91.   szgdg.NextGadget = &tagdg ;
  92.   tagdg.LeftEdge  = prj->win->Width - 10 ;
  93.   tagdg.TopEdge   = prj->win->Height - 10 ;
  94.   
  95.   AddGList(prj->win, &szgdg, 0, 2, NULL) ;
  96.    
  97.   RefreshGList(&szgdg, prj->win, NULL, -1) ;                                                           
  98.   UnlockPubScreen(NULL, WBScreen) ;
  99.   setColors(prj) ;
  100. }
  101.  
  102.  
  103. void setWindow(idWin * prj) {
  104.   CloseWindow(prj->win) ;
  105.   prj->wb = LockPubScreen("Workbench") ;
  106.   
  107.   free_bitmap(prj) ;
  108.   init_bitmap(prj) ;
  109.   
  110.   prj->win = OpenWindowTags(NULL, WA_Left,    prj->backWin.posX,
  111.                                              WA_Top,        prj->backWin.posY,
  112.                                              WA_Width,    prj->backWin.width,
  113.                                              WA_Height,    prj->backWin.height,
  114.                                              WA_IDCMP,    IDCMP,
  115.                                  WA_MinWidth,     50,
  116.                                  WA_MinHeight,   50,
  117.                                  WA_MaxHeight,   MAXH,
  118.                                  WA_MaxWidth,    MAXH, 
  119.                                              WA_Flags,    WFLG_BORDERLESS,
  120.                                              WA_ScreenTitle, "BackClock", 
  121.                                              WA_NewLookMenus, TRUE,
  122.                                              WA_PubScreenName, "Workbench", TAG_DONE) ;
  123.   RemoveGList(prj->win, &szgdg, 2) ;
  124.                                              
  125.   szgdg.Width  = prj->win->Width ;
  126.   szgdg.NextGadget = &tagdg ;
  127.   tagdg.LeftEdge  = prj->win->Width - 10 ;
  128.   tagdg.TopEdge   = prj->win->Height - 10 ;
  129.   
  130.   AddGList(prj->win, &szgdg, 0, 2, NULL) ;
  131.    
  132.   RefreshGList(&szgdg, prj->win, NULL, -1) ;
  133.  
  134.   UnlockPubScreen(NULL, prj->wb) ; 
  135. //  ChangeWindowBox(prj->win, prj->backWin.posX, prj->backWin.posY, prj->backWin.width, prj->backWin.height) ;
  136.   reinit_win(prj) ;
  137. }
  138.